Optimal. Leaf size=90 \[ -\frac {(A-B) x}{a}+\frac {B x}{2 a}+\frac {(A-B) \sin (c+d x)}{a d}+\frac {B \cos (c+d x) \sin (c+d x)}{2 a d}+\frac {(A-B) \sin (c+d x)}{a d (1+\cos (c+d x))} \]
[Out]
________________________________________________________________________________________
Rubi [A]
time = 0.08, antiderivative size = 99, normalized size of antiderivative = 1.10, number of steps
used = 2, number of rules used = 2, integrand size = 31, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.065, Rules used = {3056, 2813}
\begin {gather*} \frac {2 (A-B) \sin (c+d x)}{a d}+\frac {(A-B) \sin (c+d x) \cos ^2(c+d x)}{d (a \cos (c+d x)+a)}-\frac {(2 A-3 B) \sin (c+d x) \cos (c+d x)}{2 a d}-\frac {x (2 A-3 B)}{2 a} \end {gather*}
Antiderivative was successfully verified.
[In]
[Out]
Rule 2813
Rule 3056
Rubi steps
\begin {align*} \int \frac {\cos ^2(c+d x) (A+B \cos (c+d x))}{a+a \cos (c+d x)} \, dx &=\frac {(A-B) \cos ^2(c+d x) \sin (c+d x)}{d (a+a \cos (c+d x))}+\frac {\int \cos (c+d x) (2 a (A-B)-a (2 A-3 B) \cos (c+d x)) \, dx}{a^2}\\ &=-\frac {(2 A-3 B) x}{2 a}+\frac {2 (A-B) \sin (c+d x)}{a d}-\frac {(2 A-3 B) \cos (c+d x) \sin (c+d x)}{2 a d}+\frac {(A-B) \cos ^2(c+d x) \sin (c+d x)}{d (a+a \cos (c+d x))}\\ \end {align*}
________________________________________________________________________________________
Mathematica [B] Leaf count is larger than twice the leaf count of optimal. \(197\) vs. \(2(90)=180\).
time = 0.49, size = 197, normalized size = 2.19 \begin {gather*} \frac {\cos \left (\frac {1}{2} (c+d x)\right ) \sec \left (\frac {c}{2}\right ) \left (-4 (2 A-3 B) d x \cos \left (\frac {d x}{2}\right )-4 (2 A-3 B) d x \cos \left (c+\frac {d x}{2}\right )+20 A \sin \left (\frac {d x}{2}\right )-20 B \sin \left (\frac {d x}{2}\right )+4 A \sin \left (c+\frac {d x}{2}\right )-4 B \sin \left (c+\frac {d x}{2}\right )+4 A \sin \left (c+\frac {3 d x}{2}\right )-3 B \sin \left (c+\frac {3 d x}{2}\right )+4 A \sin \left (2 c+\frac {3 d x}{2}\right )-3 B \sin \left (2 c+\frac {3 d x}{2}\right )+B \sin \left (2 c+\frac {5 d x}{2}\right )+B \sin \left (3 c+\frac {5 d x}{2}\right )\right )}{8 a d (1+\cos (c+d x))} \end {gather*}
Antiderivative was successfully verified.
[In]
[Out]
________________________________________________________________________________________
Maple [A]
time = 0.14, size = 105, normalized size = 1.17
method | result | size |
derivativedivides | \(\frac {A \tan \left (\frac {d x}{2}+\frac {c}{2}\right )-B \tan \left (\frac {d x}{2}+\frac {c}{2}\right )-\frac {2 \left (\left (\frac {3 B}{2}-A \right ) \left (\tan ^{3}\left (\frac {d x}{2}+\frac {c}{2}\right )\right )+\left (\frac {B}{2}-A \right ) \tan \left (\frac {d x}{2}+\frac {c}{2}\right )\right )}{\left (1+\tan ^{2}\left (\frac {d x}{2}+\frac {c}{2}\right )\right )^{2}}-\left (2 A -3 B \right ) \arctan \left (\tan \left (\frac {d x}{2}+\frac {c}{2}\right )\right )}{d a}\) | \(105\) |
default | \(\frac {A \tan \left (\frac {d x}{2}+\frac {c}{2}\right )-B \tan \left (\frac {d x}{2}+\frac {c}{2}\right )-\frac {2 \left (\left (\frac {3 B}{2}-A \right ) \left (\tan ^{3}\left (\frac {d x}{2}+\frac {c}{2}\right )\right )+\left (\frac {B}{2}-A \right ) \tan \left (\frac {d x}{2}+\frac {c}{2}\right )\right )}{\left (1+\tan ^{2}\left (\frac {d x}{2}+\frac {c}{2}\right )\right )^{2}}-\left (2 A -3 B \right ) \arctan \left (\tan \left (\frac {d x}{2}+\frac {c}{2}\right )\right )}{d a}\) | \(105\) |
risch | \(-\frac {x A}{a}+\frac {3 B x}{2 a}-\frac {i {\mathrm e}^{i \left (d x +c \right )} A}{2 d a}+\frac {i {\mathrm e}^{i \left (d x +c \right )} B}{2 d a}+\frac {i {\mathrm e}^{-i \left (d x +c \right )} A}{2 d a}-\frac {i {\mathrm e}^{-i \left (d x +c \right )} B}{2 d a}+\frac {2 i A}{d a \left ({\mathrm e}^{i \left (d x +c \right )}+1\right )}-\frac {2 i B}{d a \left ({\mathrm e}^{i \left (d x +c \right )}+1\right )}+\frac {\sin \left (2 d x +2 c \right ) B}{4 d a}\) | \(156\) |
norman | \(\frac {\frac {\left (A -B \right ) \left (\tan ^{7}\left (\frac {d x}{2}+\frac {c}{2}\right )\right )}{d a}+\frac {\left (3 A -2 B \right ) \tan \left (\frac {d x}{2}+\frac {c}{2}\right )}{d a}+\frac {\left (5 A -6 B \right ) \left (\tan ^{5}\left (\frac {d x}{2}+\frac {c}{2}\right )\right )}{d a}-\frac {\left (2 A -3 B \right ) x}{2 a}+\frac {7 \left (A -B \right ) \left (\tan ^{3}\left (\frac {d x}{2}+\frac {c}{2}\right )\right )}{d a}-\frac {3 \left (2 A -3 B \right ) x \left (\tan ^{2}\left (\frac {d x}{2}+\frac {c}{2}\right )\right )}{2 a}-\frac {3 \left (2 A -3 B \right ) x \left (\tan ^{4}\left (\frac {d x}{2}+\frac {c}{2}\right )\right )}{2 a}-\frac {\left (2 A -3 B \right ) x \left (\tan ^{6}\left (\frac {d x}{2}+\frac {c}{2}\right )\right )}{2 a}}{\left (1+\tan ^{2}\left (\frac {d x}{2}+\frac {c}{2}\right )\right )^{3}}\) | \(198\) |
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Maxima [B] Leaf count of result is larger than twice the leaf count of optimal. 225 vs.
\(2 (86) = 172\).
time = 0.48, size = 225, normalized size = 2.50 \begin {gather*} -\frac {B {\left (\frac {\frac {\sin \left (d x + c\right )}{\cos \left (d x + c\right ) + 1} + \frac {3 \, \sin \left (d x + c\right )^{3}}{{\left (\cos \left (d x + c\right ) + 1\right )}^{3}}}{a + \frac {2 \, a \sin \left (d x + c\right )^{2}}{{\left (\cos \left (d x + c\right ) + 1\right )}^{2}} + \frac {a \sin \left (d x + c\right )^{4}}{{\left (\cos \left (d x + c\right ) + 1\right )}^{4}}} - \frac {3 \, \arctan \left (\frac {\sin \left (d x + c\right )}{\cos \left (d x + c\right ) + 1}\right )}{a} + \frac {\sin \left (d x + c\right )}{a {\left (\cos \left (d x + c\right ) + 1\right )}}\right )} + A {\left (\frac {2 \, \arctan \left (\frac {\sin \left (d x + c\right )}{\cos \left (d x + c\right ) + 1}\right )}{a} - \frac {2 \, \sin \left (d x + c\right )}{{\left (a + \frac {a \sin \left (d x + c\right )^{2}}{{\left (\cos \left (d x + c\right ) + 1\right )}^{2}}\right )} {\left (\cos \left (d x + c\right ) + 1\right )}} - \frac {\sin \left (d x + c\right )}{a {\left (\cos \left (d x + c\right ) + 1\right )}}\right )}}{d} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Fricas [A]
time = 0.35, size = 83, normalized size = 0.92 \begin {gather*} -\frac {{\left (2 \, A - 3 \, B\right )} d x \cos \left (d x + c\right ) + {\left (2 \, A - 3 \, B\right )} d x - {\left (B \cos \left (d x + c\right )^{2} + {\left (2 \, A - B\right )} \cos \left (d x + c\right ) + 4 \, A - 4 \, B\right )} \sin \left (d x + c\right )}{2 \, {\left (a d \cos \left (d x + c\right ) + a d\right )}} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Sympy [B] Leaf count of result is larger than twice the leaf count of optimal. 665 vs.
\(2 (68) = 136\).
time = 0.92, size = 665, normalized size = 7.39 \begin {gather*} \begin {cases} - \frac {2 A d x \tan ^{4}{\left (\frac {c}{2} + \frac {d x}{2} \right )}}{2 a d \tan ^{4}{\left (\frac {c}{2} + \frac {d x}{2} \right )} + 4 a d \tan ^{2}{\left (\frac {c}{2} + \frac {d x}{2} \right )} + 2 a d} - \frac {4 A d x \tan ^{2}{\left (\frac {c}{2} + \frac {d x}{2} \right )}}{2 a d \tan ^{4}{\left (\frac {c}{2} + \frac {d x}{2} \right )} + 4 a d \tan ^{2}{\left (\frac {c}{2} + \frac {d x}{2} \right )} + 2 a d} - \frac {2 A d x}{2 a d \tan ^{4}{\left (\frac {c}{2} + \frac {d x}{2} \right )} + 4 a d \tan ^{2}{\left (\frac {c}{2} + \frac {d x}{2} \right )} + 2 a d} + \frac {2 A \tan ^{5}{\left (\frac {c}{2} + \frac {d x}{2} \right )}}{2 a d \tan ^{4}{\left (\frac {c}{2} + \frac {d x}{2} \right )} + 4 a d \tan ^{2}{\left (\frac {c}{2} + \frac {d x}{2} \right )} + 2 a d} + \frac {8 A \tan ^{3}{\left (\frac {c}{2} + \frac {d x}{2} \right )}}{2 a d \tan ^{4}{\left (\frac {c}{2} + \frac {d x}{2} \right )} + 4 a d \tan ^{2}{\left (\frac {c}{2} + \frac {d x}{2} \right )} + 2 a d} + \frac {6 A \tan {\left (\frac {c}{2} + \frac {d x}{2} \right )}}{2 a d \tan ^{4}{\left (\frac {c}{2} + \frac {d x}{2} \right )} + 4 a d \tan ^{2}{\left (\frac {c}{2} + \frac {d x}{2} \right )} + 2 a d} + \frac {3 B d x \tan ^{4}{\left (\frac {c}{2} + \frac {d x}{2} \right )}}{2 a d \tan ^{4}{\left (\frac {c}{2} + \frac {d x}{2} \right )} + 4 a d \tan ^{2}{\left (\frac {c}{2} + \frac {d x}{2} \right )} + 2 a d} + \frac {6 B d x \tan ^{2}{\left (\frac {c}{2} + \frac {d x}{2} \right )}}{2 a d \tan ^{4}{\left (\frac {c}{2} + \frac {d x}{2} \right )} + 4 a d \tan ^{2}{\left (\frac {c}{2} + \frac {d x}{2} \right )} + 2 a d} + \frac {3 B d x}{2 a d \tan ^{4}{\left (\frac {c}{2} + \frac {d x}{2} \right )} + 4 a d \tan ^{2}{\left (\frac {c}{2} + \frac {d x}{2} \right )} + 2 a d} - \frac {2 B \tan ^{5}{\left (\frac {c}{2} + \frac {d x}{2} \right )}}{2 a d \tan ^{4}{\left (\frac {c}{2} + \frac {d x}{2} \right )} + 4 a d \tan ^{2}{\left (\frac {c}{2} + \frac {d x}{2} \right )} + 2 a d} - \frac {10 B \tan ^{3}{\left (\frac {c}{2} + \frac {d x}{2} \right )}}{2 a d \tan ^{4}{\left (\frac {c}{2} + \frac {d x}{2} \right )} + 4 a d \tan ^{2}{\left (\frac {c}{2} + \frac {d x}{2} \right )} + 2 a d} - \frac {4 B \tan {\left (\frac {c}{2} + \frac {d x}{2} \right )}}{2 a d \tan ^{4}{\left (\frac {c}{2} + \frac {d x}{2} \right )} + 4 a d \tan ^{2}{\left (\frac {c}{2} + \frac {d x}{2} \right )} + 2 a d} & \text {for}\: d \neq 0 \\\frac {x \left (A + B \cos {\left (c \right )}\right ) \cos ^{2}{\left (c \right )}}{a \cos {\left (c \right )} + a} & \text {otherwise} \end {cases} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Giac [A]
time = 0.47, size = 124, normalized size = 1.38 \begin {gather*} -\frac {\frac {{\left (d x + c\right )} {\left (2 \, A - 3 \, B\right )}}{a} - \frac {2 \, {\left (A \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right ) - B \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )\right )}}{a} - \frac {2 \, {\left (2 \, A \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{3} - 3 \, B \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{3} + 2 \, A \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right ) - B \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )\right )}}{{\left (\tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{2} + 1\right )}^{2} a}}{2 \, d} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Mupad [B]
time = 0.49, size = 107, normalized size = 1.19 \begin {gather*} \frac {\left (2\,A-3\,B\right )\,{\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )}^3+\left (2\,A-B\right )\,\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )}{d\,\left (a\,{\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )}^4+2\,a\,{\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )}^2+a\right )}-\frac {x\,\left (2\,A-3\,B\right )}{2\,a}+\frac {\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )\,\left (A-B\right )}{a\,d} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________